<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>cors跨域测试</title>
    <script src="https://cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
    <script type="text/javascript">
        function crosGet(){
            $.ajax({
                type:'get',
                url:'http://localhost:8080/api/cors/get',
                dateType: 'json',
                data:{},
                success: function (data) {
                    $("#getRes").html('请求成功。' + data);
                },
                error: function (data) {
                    console.log('请求失败：' + data);
                    $("#getRes").html('请求失败！！！' + JSON.stringify(data));
                }
            });
        }
 
        function crosPost(){
            $.ajax({
                type:'post',
                url:'http://localhost:8080/api/cors/post',
                dateType: 'json',
                data:{},
                success: function (data) {
                    $("#postRes").html('请求成功。' + data);
                },
                error: function (data) {
                    $("#postRes").html('请求失败！！！' + JSON.stringify(data));
                }
            });
        }
    </script>
</head>
<body>
<button οnclick="crosGet()">get跨域测试</button>
<div id="getRes" style="width:80%;height:50px;background-color:#ccc;"></div>
<hr/>
<button οnclick="crosPost()">post跨域测试</button>
<div id="postRes" style="width:80%;height:50px;background-color:#ccc;"></div>
</body>
</html>
